var sideBar = $('div.col-sm-3 div.side-bar')
var menuBar = $('div.menus div.menu-bar');

var execFlag = false

$(document).ready(function () {
    $(window).scroll(function () {
        if ($(window).scrollTop() > 800)
            $('div.go-top').show();
        else
            $('div.go-top').hide();
    });
    $('div.go-top').click(function () {
        $('html, body').animate({ scrollTop: 0 }, 1000);
    });
});



$(document).ready(function () {
    // sample time
    for (let i = 1; i <= 15; i++) {
        var post_id = '#post-time' + String(i);
        $(post_id).text(Date().toLocaleString());
    }
});

//bug fix
$(document).ready(function () {
    var menuBar = $('div.menus div.menu-bar');
    var card_content = $('div.post div.card-content')
    var row = $('div.post div.card div.row')
    var height = card_content.height() + row.height()
    var width = window.innerWidth;
    if (width >= 770) {
        menuBar.attr({
            'style': 'height:' + String(height) + 'px;'
        });

        menuBar.show()
        sideBar.show()
    }
    else {
        menuBar.hide()
        sideBar.hide()
    }
});

/*
function goTop() {
    var obj = document.getElementsByClassName("go-top");

    function getScrollTop() {
        var scrollTop = window.pageYOffset | document.documentElement.scrollTop | document.body.scrollTop | 0
        return scrollTop
    }
    function setScrollTop(value) {
        document.documentElement.scrollTop = value
        document.body.scrollTop = value
    }
    window.onscroll = function() { getScrollTop > 800 ? obj.style.display = "display" : obj.style.display = "none" }
    obj.onclick() = function() {
        var goTop = setInterval(moveHandler, 10)
        function moveHandler() {
            setScrollTop(getScrollTop / 1.1)
            if (getScrollTop < 1) clearInterval(goTop)
        }
    }
}

goTop()

*/
window.addEventListener('resize', function (event) {

    var width = window.innerWidth;
    var height = window.innerHeight;
    if (width <= 770) {
        menuBar.hide()
        sideBar.hide()
    }
    else {
        menuBar.attr({
            'style': 'height:' + String(height) + 'px;'
        });
        menuBar.show()
        sideBar.show()
    }
    console.log("width: ", width, "Height: ", height)
});

/*
window.addEventListener('scroll', function(window, event){
    console.log(event);
});
*/


// new js code


